<template>
  <h3>通过vuex来获取接口数据</h3>
  <ul>
    <li v-for="item in list" :key="item._id">{{ item.title }}</li>
  </ul>
</template>

<script>
import { mapActions, mapState } from "vuex";

export default {
  // data() {
  //   return {
  //     list: [],
  //   };
  // },
  // mounted() {
  //   fetch("http://www.pudge.wang:3080/api/rated/list")
  //     .then((response) => response.json())
  //     .then((res) => {
  //       console.log(res);
  //       this.list = res.result;
  //     });
  // },

  computed: mapState("b", ["list"]),
  // computed: mapState({
  //   list: (state) => state.b.list,
  // }),
  methods: {
    ...mapActions("b", ["asyncGetList"]),
  },
  mounted() {
    this.asyncGetList().then(() => {
      console.log(document.querySelector("ul").offsetHeight);
    });
    // this.$nextTick(() => {
    //   console.log(document.querySelector("ul").offsetHeight);
    // });
  },
};
</script>
